//
//  BKMyorderSplitCell.m
//  bestkeep
//
//  Created by Mr. Wu on 16/12/21.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKMyorderSplitCell.h"
#import "BK_OD_Tool.h"


#import "BK_OD_Color.h"


@implementation BKMyorderSplitCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        number = 1;
        _buttonSelect =[UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonSelect addTarget:self action:@selector(buttonSelect:) forControlEvents:UIControlEventTouchUpInside];
    [_buttonSelect setImage:[UIImage imageNamed:@"ordersplit_unselect_image"] forState:UIControlStateNormal];
    [_buttonSelect setImage:[UIImage imageNamed:@"ordersplit_select_image"] forState:UIControlStateSelected];
        [self.contentView addSubview:_buttonSelect];
        
        _labelColor =[[UILabel alloc]init];
        _labelColor.textColor = kOrderMediumGrey;
        _labelColor.font =[UIFont systemFontOfSize:14.0];
        [self.contentView addSubview:_labelColor];
        _labelName =[[UILabel alloc]init];
        _labelName.font =[UIFont systemFontOfSize:14.0];
        [self.contentView addSubview:_labelName];
        _labelZhuangTai =[[UILabel alloc]init];
        _labelZhuangTai.font =[UIFont systemFontOfSize:14.0];
        [self.contentView addSubview:_labelZhuangTai];
        _imageShop =[[UIImageView alloc]init];
        [self.contentView addSubview:_imageShop];
        
        [self laoutContrians];
        
        
    }
    return self;
}
-(void)laoutContrians{
    
 
    
    [_buttonSelect mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView.mas_left).offset(ApplicationBackGauge);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.width.equalTo(@20);
        make.height.equalTo(@20);
    }];
    [_imageShop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_buttonSelect.mas_right).offset(10);
        make.top.equalTo(self.contentView.mas_top).offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
        make.width.equalTo(@80);
        make.height.equalTo(@80);
    }];
    [_labelName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imageShop.mas_right).offset(10);
        make.top.equalTo(self.contentView.mas_top).offset(15);
        make.height.equalTo(@20);
    }];
    [_labelColor mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imageShop.mas_right).offset(10);
        make.top.equalTo(_labelName.mas_bottom).offset(5);
        make.height.equalTo(@20);
    }];
    [_labelZhuangTai mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imageShop.mas_right).offset(10);
        make.top.equalTo(_labelColor.mas_bottom).offset(5);
        make.height.equalTo(@20);
    }];

    
}


-(void)buttonSelect:(UIButton *)button
{
    [self.delegate addItem:self.model.itemId];
    
    button.selected = !button.selected;
   
   
      }
-(void)setModel:(BK_My_DetailOrder_OrderList_Model *)model{
    _model = model;
    
    [_imageShop load:model.goods_img];
    _labelName.text = model.goods_name;
    _labelColor.text = model.sale_property;
    if ([model.availableDeliver isEqualToString:@"1"]) {
        _labelZhuangTai.textColor = [UIColor redColor];
       _labelZhuangTai.text = @"未到货";
        _buttonSelect.hidden = YES;
    }else {
       _labelZhuangTai.textColor = kOrderBKGreen;
        _labelZhuangTai.text = @"已到货";
    }
  }
@end
